{  Statement: http://codeforces.ru/problemset/problem/112/D
	Verdict: Accepted
}
uses
                SysUtils, Math;

var
        i, n, x, y, tt, xx, yy, ans, j : longint;
        a : array[0..100010] of longint;

begin  
        read(n);
        fillchar(a, sizeof(a), 0);
        for i := 1 to n do begin
                read(x, y);
                tt := trunc(sqrt(x));
                ans := 0;
                for j := 1 to tt do
                        if x mod j = 0 then begin
                                xx := x div j;
                                yy := x div xx;
                                inc(ans, 2);
                                if xx = yy then begin
                                        dec(ans);
                                        if a[xx] >= i - y then dec(ans);
                                end else begin
                                        if a[xx] >= i - y then dec(ans);
                                        if a[yy] >= i - y then dec(ans);
                                end;
                                a[xx] := i;
                                a[yy] := i;
                        end;
                writeln(ans);
        end;
end.